//
//  RYErjixuanzeViewController.m
//  SheYangBigData
//
//  Created by 宋海胜 on 2021/1/17.
//  Copyright © 2021 叁拾叁. All rights reserved.
//

#import "RYErjixuanzeViewController.h"
#import "WMZDialog.h"
@interface RYErjixuanzeViewController ()
{
    WMZDialog * alert;
    UIView * sview;
    UIView * fview;
}
@end

@implementation RYErjixuanzeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    
    sview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height-200)];
    sview.backgroundColor = [UIColor redColor];
    [self.view addSubview:sview];
}


- (void)setupErjiXuanze: (UIView *)view color: (UIColor *)color  datas:(NSArray *)datas {
    DialogWeakSelf(self)
    alert =  Dialog();
    id data = nil;
    data = datas;//[self getArr1];
    
    alert
    //下拉无限级菜单选中事件
    .wEventMenuClickSet( ^(id anyID, NSInteger section, NSInteger row) {
        //外部更新数据
        DialogStrongSelf(weakObject)
        [strongObject selectMenu:section withRow:row];
        NSLog(@"菜单点击方法 当前选中值:%@ 当前选中列:%ld 当前选中行:%ld",anyID,section,row);
        self.choice(section, row);
    })
    .wTypeSet(DialogTypeMenusSelect)
    .wDataSet(data);
    
        //带打钩
        alert.wSelectShowCheckedSet(YES)
        .wTextAlignmentSet(NSTextAlignmentLeft);
        //改变出现的位置
        alert.wTapViewSet(view);
    alert.wMainRadiusSet(0); // 圆角
    alert.wTableViewColorSet(@[color, [UIColor whiteColor]]);
    alert.wShadowColorSet([UIColor clearColor]);
    alert.wStart();
//    alert.wStartView(sview);
}

-(void)dierlie:(NSArray *)datas dierlieNoData:(BOOL)noData {
    if (noData) {
        [alert closeView];
    } else {
        alert.wDataSet(datas);
        alert.wStart();
    }
}

- (void)selectMenu:(NSInteger)section withRow:(NSInteger)row{
    //刷新下一列显示的数据 用于从外部传入数据
//    if (section == 1) {
//        
//        [alert updateMenuChildrenDataWithSection:section+1 withUpdateChildren:NO withData:@[
//                                                                                            @{
//                                                                                                @"name":[NSString stringWithFormat:@"好借好还就1111%ld_%ld",section+1,row],
//                                                                                                @"id":@"111",
//                                                                                                },
//                                                                                            @{
//                                                                                                @"name":[NSString stringWithFormat:@"%ld_%ld",section+1,row],
//                                                                                                @"id":@"112",
//                                                                                                },
//                                                                                            @{
//                                                                                                @"name":[NSString stringWithFormat:@"%ld_%ld",section+1,row],
//                                                                                                @"id":@"113",
//                                                                                                },
//                                                                                            ]];
//    }
}


//两层
- (NSArray*)getArr1{
    return @[
             @{
                 @"name":@"数据1",
                 @"id":@"1",
                 @"children":@[
                         @{
                             @"name":@"数据11数据11数据11数据11数据11数据11数据11数据11数据11",
                             @"id":@"11",
                             @"children":@[]
                             },
                         @{
                             @"name":@"数据12",
                             @"id":@"12",
                             @"children":@[]
                             },
                         @{
                             @"name":@"数据13",
                             @"id":@"13",
                             @"children":@[]
                             },
                         ]
                 },
             @{
                 @"name":@"数据2",
                 @"id":@"2",
                 @"children":@[]
                 },
             @{
                 @"name":@"数据2",
                 @"id":@"2",
                 @"children":@[]
                 },
             @{
                 @"name":@"数据2",
                 @"id":@"2",
                 @"children":@[]
                 },
             @{
                 @"name":@"数据2",
                 @"id":@"2",
                 @"children":@[]
                 },
             @{
                 @"name":@"数据3",
                 @"id":@"3",
                 @"children":@[
                         @{
                             @"name":@"数据31",
                             @"id":@"31",
                             @"children":@[]
                             },
                         @{
                             @"name":@"数据32",
                             @"id":@"32",
                             @"children":@[]
                             },
                         @{
                             @"name":@"数据33",
                             @"id":@"33",
                             @"children":@[]
                             },
                         ]
                 },
             ];
}



- (void)setupSheet:(NSArray *)datas view:(UIView *)view color: (UIColor *)color {
    
    Dialog()
    .wTypeSet(DialogTypeSheet)
    .wDataSet(datas)
    .wTitleSet(@"配送方式选择")
    //完成操作事件
    .wEventFinishSet(^(id anyID,NSIndexPath *path, DialogType type) {
        NSLog(@"%@",anyID);
    })
    
    //默认选中第二个
    .wListDefaultValueSet(@[@(0)])
    //默认选中男
//            .wListDefaultValueSet(@[@"男"])
    //改变出现的位置
    .wTapViewSet(view)
    .wStart();
}

@end

